﻿@model HdipCricketClub.ViewModels.ScorecardAbandonedFixtureReInputScoresBatAndBowlViewModel

@{
    ViewBag.Title = "ReInputAbandonedFixtureScoresBowledOnly";
}

<h2>ReInputAbandonedFixtureScoresBowledOnly</h2>

@using (@Html.BeginForm("UpdateAbandonedFixtureScoresBowledOnly", "ScorecardAbandonedFixture", FormMethod.Post))
{
<fieldset>
<legend>Fixture</legend>
<br/>
@Html.HiddenFor(ModelItem => Model.ScorecardFixture.fixture_id)
@Html.HiddenFor(ModelItem => Model.ScorecardFixture.team_id)
@Html.HiddenFor(ModelItem => Model.ScorecardFixture.opponent_id)
@Html.HiddenFor(ModelItem => Model.ScorecardFixture.type)
@Html.HiddenFor(ModelItem => Model.ScorecardFixture.home)
@Html.HiddenFor(ModelItem => Model.ScorecardFixture.date)
@Html.HiddenFor(ModelItem => Model.ScorecardFixture.start_time)
@Html.HiddenFor(ModelItem => Model.ScorecardFixture.no_of_players)
@Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.fixture_id)
@Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.result_id)
@Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.scorecard_entered)
@Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.won_toss)
@Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.batted_first)
@Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.batted)
@Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.bowled)

@Html.DisplayFor(ModelItem => Model.ScorecardFixture.Team.Club.ShortName) @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Team.name)
vs @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Opponent.club_name) @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Opponent.team_name)
<br/>
Played on: @Html.DisplayFor(ModelItem => Model.ScorecardFixture.date)
<br/>
At:
@if (Model.ScorecardFixture.home)
{
    @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Team.Club.ShortName)
}
else
{
    @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Opponent.club_name)
}
<br/><br/>
@if (Model.ScorecardHeaderDetail.won_toss)
{
    @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Team.Club.ShortName)
    @:won the toss and elected to bat.
}
else
{
    @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Opponent.club_name)
    @:won the toss and elected to field first.
}
</fieldset>
<fieldset>
<legend>Innings of @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Opponent.club_name)</legend>
<br/>
@if (Model.OpponentBatsmenErrorMessages.Count() > 0)
{
        <span class="team_input_error_header">Please correct the following other errors</span><br />
        foreach (var item in Model.OpponentBatsmenErrorMessages)
        {
            <span class="team_input_error">@Html.DisplayFor(modelItem => item)</span><br/>    
        }
}
    @if (Model.OpponentOtherDetailErrorMessages.Count() > 0)
    {
        <span class="team_input_error_header">Please correct the following other errors</span><br />
        foreach (var item in Model.OpponentOtherDetailErrorMessages)
        {
            <span class="team_input_error">@Html.DisplayFor(modelItem => item)</span><br />
        }
    }
    @if (Model.ScorecardOpponentErrorMessages.Count() > 0)
    {
        <span class="team_input_error_header">Please correct the following scorecard errors</span><br />
        foreach (var item in Model.ScorecardOpponentErrorMessages)
        {
            <span class="team_input_error">@Html.DisplayFor(modelItem => item)</span><br />
        }
    }
<br/>
<table>
    <tr>
        <th></th>
        <th>
            Name
        </th>
        <th>
            How Out
        </th>
        <th>
            Fielder
        </th>
        <th>
            Bowler
        </th>
        <th>
            Runs
        </th>
    </tr>
    @foreach (var item in Model.OpponentBatsmen)
    {
        <tr>
                @Html.HiddenFor(modelItem => item.op_fixture_id)
                @Html.HiddenFor(modelItem => item.op_batsman_number)
                @Html.HiddenFor(modelItem => item.op_player_name)
            <td class="column_ids">
                @Html.DisplayFor(modelItem => item.op_batsman_number)
            </td>
            <td class="column_names">
                @Html.DisplayFor(modelItem => item.op_player_name)
            </td>
            <td class="column_names">
                @if (item.op_how_out == null)
                {
                    @Html.DropDownListFor(modelitem => item.op_how_out, new SelectList(Model.DismissalTypes, "dismissal_id", "type"), string.Empty)
                }
                @if (item.op_how_out != null)
                {
                    @Html.DropDownListFor(modelitem => item.op_how_out, new SelectList(Model.DismissalTypes, "dismissal_id", "type", item.op_how_out), string.Empty)
                }
            </td>
            <td class="column_names">
                @if (item.op_fielder_name == null)
                {
                    @Html.DropDownListFor(modelItem => item.op_fielder_name, new SelectList(Model.ClubBatsmen, "player_id", "Member.InitialAndLastName"), string.Empty)
                }
                @if (item.op_fielder_name != null)
                {
                    @Html.DropDownListFor(modelItem => item.op_fielder_name, new SelectList(Model.ClubBatsmen, "player_id", "Member.InitialAndLastName", item.op_fielder_name), string.Empty)
                }
            </td>
            <td class="column_names">
                @if (item.op_bowler_name == null)
                {
                    @Html.DropDownListFor(modelItem => item.op_bowler_name, new SelectList(Model.ClubBowlers, "player_id", "Member.InitialAndLastName"), string.Empty)
                }
                @if (item.op_bowler_name != null)
                {
                    @Html.DropDownListFor(modelItem => item.op_bowler_name, new SelectList(Model.ClubBowlers, "player_id", "Member.InitialAndLastName", item.op_bowler_name), string.Empty)
                }
            </td>
            <td class="column_numbers">
                @Html.EditorFor(modelItem => item.op_batting_runs)
            </td>
        </tr>
    }
    <tr>
            <td></td>
            <td></td>
            <td></td>
            <td>
                Sub Total:
            </td>
            <td></td>
            <td class="column_numbers">
                @Html.DisplayFor(ModelItem => Model.TotalOpponentBatsmenRuns)
            </td>
        </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td>
            Byes:
        </td>
        <td class="column_numbers">
            @Html.EditorFor(ModelItem => Model.OpponentOtherDetail.byes)
        </td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td>
            Leg Byes:
        </td>
        <td class="column_numbers">
            @Html.EditorFor(ModelItem => Model.OpponentOtherDetail.leg_byes)
        </td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td>
            Wides:
        </td>
        <td class="column_numbers">
            @Html.EditorFor(ModelItem => Model.OpponentOtherDetail.wides)
        </td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td>
            No Balls:
        </td>
        <td class="column_numbers">
            @Html.EditorFor(ModelItem => Model.OpponentOtherDetail.no_balls)
        </td>
        <td></td>
    </tr>
    <tr>
            <td></td>
            <td></td>
            <td></td>
            <td>
                Total Extras:
            </td>
            <td></td>
            <td class="column_numbers">
                @Html.DisplayFor(ModelItem => Model.TotalOpponentExtras)
            </td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td>
                Total For
            </td>
            <td>
                @Html.DisplayFor(ModelItem => Model.TotalOpponentWicketsLost) wkts
            </td>
            <td class="column_numbers">
                @Html.DisplayFor(ModelItem => Model.TotalOpponentScore)
            </td>
        </tr>
</table>
<br/>
<br/>
@if (Model.ClubBowlersErrorMessages.Count() > 0)
{
    <span class="team_input_error_header">Please correct the following bowler errors</span><br/>
    foreach (var item in Model.ClubBowlersErrorMessages)
    {
        <span class="team_input_error">@Html.DisplayFor(modelItem => item)</span><br />    
    }
}
<br/>
<table>
    <tr>
        <th></th>
        <th>
            Name:
        </th>
        <th>
            Overs:
        </th>
        <th>
            Maidens:
        </th>
        <th>
            Runs:
        </th>
        <th>
            Wickets:
        </th>
    </tr>
    @foreach (var item in Model.ClubBowlers)
    {
    <tr>
            @Html.HiddenFor(modelItem => item.fixture_id)
            @Html.HiddenFor(modelItem => item.player_id)
            @Html.HiddenFor(modelItem => item.bowler_number)
        <td class="column_ids">
            @Html.DisplayFor(modelItem => item.bowler_number)
        </td>
        <td class="column_names">
            @Html.DisplayFor(modelItem => item.Member.InitialAndLastName)   
        </td>
        <td class="column_numbers">
            @Html.EditorFor(modelItem => item.overs)
        </td>
        <td class="column_numbers">
            @Html.EditorFor(modelItem => item.maidens)
        </td>
        <td class="column_numbers">
            @Html.EditorFor(modelItem => item.bowling_runs)
        </td>
        <td class="column_numbers">
            @Html.EditorFor(modelItem => item.wickets)
        </td>
    </tr>
    }
</table>
</fieldset>
foreach (var item in Model.ClubBatsmen)
{
     @Html.HiddenFor(modelItem => item.fixture_id)
     @Html.HiddenFor(modelItem => item.player_id)
     @Html.HiddenFor(modelItem => item.batsman_number)
}
   <p>
        <input type="submit" value="Submit" />
   </p>   
}